﻿<!DOCTYPE html>
<html lang="zh_CN">

<head>
    <title>图标点</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="图形系统开发实战:进阶篇 示例">
    <meta name="author" content="hjq">
    <meta name="keywords" content="canvas,anygraph,javascript">
    <!-- frame所需脚本和样式 -->
    <link rel="stylesheet" href="../../script/bootstrap-3.3.5/css/bootstrap.min.css">   
    <link rel="stylesheet" href="../../script/codemirror/codemirror.css">
    <script src="../../script/lib/jquery-1.11.2.min.js"></script>
    <script src="../../script/codemirror/codemirror_merge.js"></script>
    <!-- 加载代码块 -->
    <link rel="stylesheet" href="../css/styles.css">
    <script src="../js/data_box.js"></script>
    <script src="../js/helper.js"></script>
    <script>
        var pageTitle = "AnyGraph 图标点类型";
        var pageDesc = "显示AnyGraph图标点类型";
    </script>
</head>

<body style="margin:10px;">
    <div id="graphWrapper" data-type="graph" style="width:800px; height:200px; border:solid 1px #CCC;"></div>
    <h3>Data</h3>
    <div id="divData" style="height:200px;"></div>
</body>

<script>
    let graph;
</script>
<script type="module">
    import { Graph, Point, Circle, BgUtil } from "../../src/index.js";

    // graph对象
    graph = new Graph({
        "target": "graphWrapper",
        "enabledGeomEvent": true
    });

    // 网格水印层
    BgUtil.generateGrid(Object.assign({ "interval": 10, "graph":graph }, graph.getSize()));
    
    // 新建绘图图层
    let layer = graph.addLayer();
    let path = "./images/marker/";
    let iconArr = ["marker_1.png", "marker_2.png", "marker_3.png", "marker_4.png", "marker_5.png", "marker_6.png", "marker_7.png", "marker_8.png", "marker_9.png", "marker.png"];

    // 在画布中绘制图像
    let srcIdx = 0;
    for (let y = 60, jj = graph.getSize().height; y < jj; y += 80) {
        for (let x = 50, ii = graph.getSize().width; x < ii; x += 114) {
			let src = (path + iconArr[srcIdx % 10]);
            let point = layer.getSource().add(new Point({ "x": x, "y": y, "src": src, "size": 32}));
            point.on("click", activeShape);
            srcIdx ++;
            if (srcIdx > 9) break;
        }
        if (srcIdx > 9) break;
    }

    // render
    graph.render();
</script>

</html>